/*
*输入数据求最大值最小值平均值，C++版，vc2010编译
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;
int readNumbers(std::vector<int> &);
void ifSuccess(int);
void _sort(std::vector<int> &);
int max(std::vector<int> &);
int min(std::vector<int> &);
double avg(std::vector<int> &);

int main()
{
	std::vector<int> num;
	cout << "please input some number,-1 to the end:" << endl;
	ifSuccess(readNumbers(num));
	_sort(num);
	cout << "the max: " << max(num) << " the min: " << min(num)
		<< " the average: " << avg(num) << endl;
		printf("%2d\n",avg(num));
	return 0;
}

void ifSuccess(int status)
{
	if(status == 0){
		cout << "Success" << endl;
	}else{
		cout << "failed" << endl;
		exit(1);
	}
}

int readNumbers(std::vector<int> &numbers)
{
	int x;
	while(cin >> x && x != -1){
		numbers.push_back(x);
	}
}

void _sort(std::vector<int> &numbers)
{
	int tmp;
	for(int i = 0;i < numbers.size();i ++)
		for(int j = i + 1;j < numbers.size();j ++){
			if(numbers[i] > numbers[j]){
				tmp = numbers[i];
				numbers[i] = numbers[j];
				numbers[j] = tmp;
			}
		}
}

int max(std::vector<int> &numbers)
{
	return numbers[numbers.size() - 1];
}

int min(std::vector<int> &numbers)
{
	return numbers[0];
}

double avg(std::vector<int> &numbers)
{
	double sum = 0;
	for(int i = 0;i < numbers.size();i ++) sum += numbers[i];
	if(numbers.size() != 0) return sum/numbers.size();
	return -1;
}